<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>访问数组值</title>
</head>

<body>
    <h1>JSON 数组</h1>
    <p>访问 JSON 对象的数组值。</p>
    <p id="demo"></p>
    <script>
        var myObj, x;
        myObj = {
            "name": "Bill Gates",
            "age": 62,
            "cars": ["Porsche", "BMW", "Volvo"]
        };
        x = myObj.cars[0];
        document.getElementById("demo").innerHTML = x;
    </script>
</body>

</html>